package com.api.tag.deletetag;

import org.springframework.beans.factory.annotation.Value;
import org.springframework.test.context.ContextConfiguration;
import org.testng.annotations.BeforeClass;
import org.testng.annotations.Test;

import com.api.test.AbstractApiTest;
import com.zyncro.api.ITagApiService;
import com.zyncro.api.exceptions.ZyncroApiException;
import com.zyncro.api.model.ObjectResultApi;
import com.zyncro.api.model.TagApi;
import com.zyncro.api.model.TagApiType;

@ContextConfiguration(locations = { "classpath:/tags/tags-context.xml" })
public class DeleteTagAdministrator extends AbstractApiTest {

	@Value("#{tagtest['user.administrator'].appId}")
	private String adminUrn;

	@Value("#{tagtest['user.administrator'].password}")
	private String adminPassword;

	private String categoryUrn;

	private String locationUrn;

	@BeforeClass
	protected void setParameters() throws Exception {

		getApi().login(adminUrn, adminPassword);

		ObjectResultApi<TagApi> resultCat = getApi().getService(ITagApiService.class).createTag("new", TagApiType.CATEGORY);
		this.categoryUrn = resultCat.getObject().getUrn();

		ObjectResultApi<TagApi> resultLoc = getApi().getService(ITagApiService.class).createTag("new", TagApiType.LOCATION);
		this.locationUrn = resultLoc.getObject().getUrn();
	}

	@Test
	public void testDeleteCategory() throws ZyncroApiException {

		getApi().getService(ITagApiService.class).deleteTag(categoryUrn);
	}

	@Test
	public void testDeleteLocation() throws ZyncroApiException {

		getApi().getService(ITagApiService.class).deleteTag(locationUrn);
	}
}
